
%%% The Ambiguity of Fishing for Fun, October 2022
%%% This file generates catch-per-trip distributions for each species and year, using the uncertainty of the estimates from MRIP 

tic;

%Summer flounder
SFdata2009=importdata('FlukeCatchPerTrip2009.txt'); 
SFdata2010=importdata('FlukeCatchPerTrip2010.txt');
SFdata2011=importdata('FlukeCatchPerTrip2011.txt');
SFdata2012=importdata('FlukeCatchPerTrip2012.txt');
SFdata2013=importdata('FlukeCatchPerTrip2013.txt');
SFdata2014=importdata('FlukeCatchPerTrip2014.txt');
SFdata2015=importdata('FlukeCatchPerTrip2015.txt');
SFdata2016=importdata('FlukeCatchPerTrip2016.txt');
SFdata2017=importdata('FlukeCatchPerTrip2017.txt');
SFdata2018=importdata('FlukeCatchPerTrip2018.txt');
SFdata2019=importdata('FlukeCatchPerTrip2019.txt');
SFdata2020=importdata('FlukeCatchPerTrip2020.txt');

%Scup
Sdata2009=importdata('ScupCatchPerTrip2009.txt'); 
Sdata2010=importdata('ScupCatchPerTrip2010.txt'); 
Sdata2011=importdata('ScupCatchPerTrip2011.txt'); 
Sdata2012=importdata('ScupCatchPerTrip2012.txt'); 
Sdata2013=importdata('ScupCatchPerTrip2013.txt'); 
Sdata2014=importdata('ScupCatchPerTrip2014.txt'); 
Sdata2015=importdata('ScupCatchPerTrip2015.txt'); 
Sdata2016=importdata('ScupCatchPerTrip2016.txt'); 
Sdata2017=importdata('ScupCatchPerTrip2017.txt'); 
Sdata2018=importdata('ScupCatchPerTrip2018.txt'); 
Sdata2019=importdata('ScupCatchPerTrip2019.txt'); 
Sdata2020=importdata('ScupCatchPerTrip2020.txt'); 

%Black sea bass
BSBdata2009=importdata('BSBCatchPerTrip2009.txt'); 
BSBdata2010=importdata('BSBCatchPerTrip2010.txt'); 
BSBdata2011=importdata('BSBCatchPerTrip2011.txt'); 
BSBdata2012=importdata('BSBCatchPerTrip2012.txt'); 
BSBdata2013=importdata('BSBCatchPerTrip2013.txt'); 
BSBdata2014=importdata('BSBCatchPerTrip2014.txt'); 
BSBdata2015=importdata('BSBCatchPerTrip2015.txt'); 
BSBdata2016=importdata('BSBCatchPerTrip2016.txt'); 
BSBdata2017=importdata('BSBCatchPerTrip2017.txt'); 
BSBdata2018=importdata('BSBCatchPerTrip2018.txt'); 
BSBdata2019=importdata('BSBCatchPerTrip2019.txt'); 
BSBdata2020=importdata('BSBCatchPerTrip2020.txt'); 

%Weakfish
Wdata2009=importdata('WeakfishCatchPerTrip2009.txt'); 
Wdata2010=importdata('WeakfishCatchPerTrip2010.txt'); 
Wdata2011=importdata('WeakfishCatchPerTrip2011.txt'); 
Wdata2012=importdata('WeakfishCatchPerTrip2012.txt'); 
Wdata2013=importdata('WeakfishCatchPerTrip2013.txt'); 
Wdata2014=importdata('WeakfishCatchPerTrip2014.txt'); 
Wdata2015=importdata('WeakfishCatchPerTrip2015.txt'); 
Wdata2016=importdata('WeakfishCatchPerTrip2016.txt'); 
Wdata2017=importdata('WeakfishCatchPerTrip2017.txt'); 
Wdata2018=importdata('WeakfishCatchPerTrip2018.txt'); 
Wdata2019=importdata('WeakfishCatchPerTrip2019.txt'); 
Wdata2020=importdata('WeakfishCatchPerTrip2020.txt'); 

%Red drum
RDdata2009=importdata('RDrumCatchPerTrip2009.txt'); 
RDdata2010=importdata('RDrumCatchPerTrip2010.txt'); 
RDdata2011=importdata('RDrumCatchPerTrip2011.txt'); 
RDdata2012=importdata('RDrumCatchPerTrip2012.txt'); 
RDdata2013=importdata('RDrumCatchPerTrip2013.txt'); 
RDdata2014=importdata('RDrumCatchPerTrip2014.txt'); 
RDdata2015=importdata('RDrumCatchPerTrip2015.txt'); 
RDdata2016=importdata('RDrumCatchPerTrip2016.txt'); 
RDdata2017=importdata('RDrumCatchPerTrip2017.txt'); 
RDdata2018=importdata('RDrumCatchPerTrip2018.txt'); 
RDdata2019=importdata('RDrumCatchPerTrip2019.txt'); 
RDdata2020=importdata('RDrumCatchPerTrip2020.txt'); 

%Main parameters
N=30;
M=25000;
T=100;
percentile=0.90; %Defines the maximum catch outcome per trip as given by anglers' beliefs. 

[SFreshaffle2009,catchSF_max09,catchSF_min09]=CatchTripDistribution(N,M,T,percentile,SFdata2009.data);
[SFreshaffle2010,catchSF_max10,catchSF_min10]=CatchTripDistribution(N,M,T,percentile,SFdata2010.data);
[SFreshaffle2011,catchSF_max11,catchSF_min11]=CatchTripDistribution(N,M,T,percentile,SFdata2011.data);
[SFreshaffle2012,catchSF_max12,catchSF_min12]=CatchTripDistribution(N,M,T,percentile,SFdata2012.data);
[SFreshaffle2013,catchSF_max13,catchSF_min13]=CatchTripDistribution(N,M,T,percentile,SFdata2013.data);
[SFreshaffle2014,catchSF_max14,catchSF_min14]=CatchTripDistribution(N,M,T,percentile,SFdata2014.data);
[SFreshaffle2015,catchSF_max15,catchSF_min15]=CatchTripDistribution(N,M,T,percentile,SFdata2015.data);
[SFreshaffle2016,catchSF_max16,catchSF_min16]=CatchTripDistribution(N,M,T,percentile,SFdata2016.data);
[SFreshaffle2017,catchSF_max17,catchSF_min17]=CatchTripDistribution(N,M,T,percentile,SFdata2017.data);
[SFreshaffle2018,catchSF_max18,catchSF_min18]=CatchTripDistribution(N,M,T,percentile,SFdata2018.data);
[SFreshaffle2019,catchSF_max19,catchSF_min19]=CatchTripDistribution(N,M,T,percentile,SFdata2019.data);
[SFreshaffle2020,catchSF_max20,catchSF_min20]=CatchTripDistribution(N,M,T,percentile,SFdata2020.data);

[Sreshaffle2009,catchS_max09,catchS_min09]=CatchTripDistribution(N,M,T,percentile,Sdata2009.data);
[Sreshaffle2010,catchS_max10,catchS_min10]=CatchTripDistribution(N,M,T,percentile,Sdata2010.data);
[Sreshaffle2011,catchS_max11,catchS_min11]=CatchTripDistribution(N,M,T,percentile,Sdata2011.data);
[Sreshaffle2012,catchS_max12,catchS_min12]=CatchTripDistribution(N,M,T,percentile,Sdata2012.data);
[Sreshaffle2013,catchS_max13,catchS_min13]=CatchTripDistribution(N,M,T,percentile,Sdata2013.data);
[Sreshaffle2014,catchS_max14,catchS_min14]=CatchTripDistribution(N,M,T,percentile,Sdata2014.data);
[Sreshaffle2015,catchS_max15,catchS_min15]=CatchTripDistribution(N,M,T,percentile,Sdata2015.data);
[Sreshaffle2016,catchS_max16,catchS_min16]=CatchTripDistribution(N,M,T,percentile,Sdata2016.data);
[Sreshaffle2017,catchS_max17,catchS_min17]=CatchTripDistribution(N,M,T,percentile,Sdata2017.data);
[Sreshaffle2018,catchS_max18,catchS_min18]=CatchTripDistribution(N,M,T,percentile,Sdata2018.data);
[Sreshaffle2019,catchS_max19,catchS_min19]=CatchTripDistribution(N,M,T,percentile,Sdata2019.data);
[Sreshaffle2020,catchS_max20,catchS_min20]=CatchTripDistribution(N,M,T,percentile,Sdata2020.data);

[BSBreshaffle2009,catchBSB_max09,catchBSB_min09]=CatchTripDistribution(N,M,T,percentile,BSBdata2009.data);
[BSBreshaffle2010,catchBSB_max10,catchBSB_min10]=CatchTripDistribution(N,M,T,percentile,BSBdata2010.data);
[BSBreshaffle2011,catchBSB_max11,catchBSB_min11]=CatchTripDistribution(N,M,T,percentile,BSBdata2011.data);
[BSBreshaffle2012,catchBSB_max12,catchBSB_min12]=CatchTripDistribution(N,M,T,percentile,BSBdata2012.data);
[BSBreshaffle2013,catchBSB_max13,catchBSB_min13]=CatchTripDistribution(N,M,T,percentile,BSBdata2013.data);
[BSBreshaffle2014,catchBSB_max14,catchBSB_min14]=CatchTripDistribution(N,M,T,percentile,BSBdata2014.data);
[BSBreshaffle2015,catchBSB_max15,catchBSB_min15]=CatchTripDistribution(N,M,T,percentile,BSBdata2015.data);
[BSBreshaffle2016,catchBSB_max16,catchBSB_min16]=CatchTripDistribution(N,M,T,percentile,BSBdata2016.data);
[BSBreshaffle2017,catchBSB_max17,catchBSB_min17]=CatchTripDistribution(N,M,T,percentile,BSBdata2017.data);
[BSBreshaffle2018,catchBSB_max18,catchBSB_min18]=CatchTripDistribution(N,M,T,percentile,BSBdata2018.data);
[BSBreshaffle2019,catchBSB_max19,catchBSB_min19]=CatchTripDistribution(N,M,T,percentile,BSBdata2019.data);
[BSBreshaffle2020,catchBSB_max20,catchBSB_min20]=CatchTripDistribution(N,M,T,percentile,BSBdata2020.data);

clearvars SFdata2009 SFdata2010 SFdata2011 SFdata2012 SFdata2013 SFdata2014 SFdata2015 SFdata2016 SFdata2017 SFdata2018 SFdata2019 SFdata2020
clearvars Sdata2009 Sdata2010 Sdata2011 Sdata2012 Sdata2013 Sdata2014 Sdata2015 Sdata2016 Sdata2017 Sdata2018 Sdata2019 Sdata2020
clearvars BSBdata2009 BSBdata2010 BSBdata2011 BSBdata2012 BSBdata2013 BSBdata2014 BSBdata2015 BSBdata2016 BSBdata2017 BSBdata2018 BSBdata2019 BSBdata2020
clearvars catchBSB_max09 catchBSB_max10 catchBSB_max11 catchBSB_max12 catchBSB_max13 catchBSB_max14 catchBSB_max15 catchBSB_max16 catchBSB_max17 catchBSB_max18 catchBSB_max19 catchBSB_max20
clearvars catchS_max09 catchS_max10 catchS_max11 catchS_max12 catchS_max13 catchS_max14 catchS_max15 catchS_max16 catchS_max17 catchS_max18 catchS_max19 catchS_max20
clearvars catchBSB_min09 catchBSB_min10 catchBSB_min11 catchBSB_min12 catchBSB_min13 catchBSB_min14 catchBSB_min15 catchBSB_min16 catchBSB_min17 catchBSB_min18 catchBSB_min19 catchBSB_min20
clearvars catchS_min09 catchS_min10 catchS_min11 catchS_min12 catchS_min13 catchS_min14 catchS_min15 catchS_min16 catchS_min17 catchS_min18 catchS_min19 catchS_min20

[Wreshaffle2009,catchW_max09,catchW_min09]=CatchTripDistribution(N,M,T,percentile,Wdata2009.data);
[Wreshaffle2010,catchW_max10,catchW_min10]=CatchTripDistribution(N,M,T,percentile,Wdata2010.data);
[Wreshaffle2011,catchW_max11,catchW_min11]=CatchTripDistribution(N,M,T,percentile,Wdata2011.data);
[Wreshaffle2012,catchW_max12,catchW_min12]=CatchTripDistribution(N,M,T,percentile,Wdata2012.data);
[Wreshaffle2013,catchW_max13,catchW_min13]=CatchTripDistribution(N,M,T,percentile,Wdata2013.data);
[Wreshaffle2014,catchW_max14,catchW_min14]=CatchTripDistribution(N,M,T,percentile,Wdata2014.data);
[Wreshaffle2015,catchW_max15,catchW_min15]=CatchTripDistribution(N,M,T,percentile,Wdata2015.data);
[Wreshaffle2016,catchW_max16,catchW_min16]=CatchTripDistribution(N,M,T,percentile,Wdata2016.data);
[Wreshaffle2017,catchW_max17,catchW_min17]=CatchTripDistribution(N,M,T,percentile,Wdata2017.data);
[Wreshaffle2018,catchW_max18,catchW_min18]=CatchTripDistribution(N,M,T,percentile,Wdata2018.data);
[Wreshaffle2019,catchW_max19,catchW_min19]=CatchTripDistribution(N,M,T,percentile,Wdata2019.data);
[Wreshaffle2020,catchW_max20,catchW_min20]=CatchTripDistribution(N,M,T,percentile,Wdata2020.data);

clearvars Wdata2009 Wdata2010 Wdata2011 Wdata2012 Wdata2013 Wdata2014 Wdata2015 Wdata2016 Wdata2017 Wdata2018 Wdata2019 Wdata2020

%Saving the output
[RDreshaffle2009,catchRD_max09,catchRD_min09]=CatchTripDistribution(N,M,T,percentile,RDdata2009.data);
save('CatchPerTrip2009','SFreshaffle2009','Sreshaffle2009','BSBreshaffle2009','Wreshaffle2009', 'RDreshaffle2009','catchSF_max09','catchSF_min09');
clearvars RDreshaffle2009 Wreshaffle2009 Sreshaffle2009 BSBreshaffle2009 SFreshaffle2009

[RDreshaffle2010,catchRD_max10,catchRD_min10]=CatchTripDistribution(N,M,T,percentile,RDdata2010.data);
save('CatchPerTrip2010','SFreshaffle2010','Sreshaffle2010','BSBreshaffle2010','Wreshaffle2010', 'RDreshaffle2010','catchSF_max10','catchSF_min10');
clearvars RDreshaffle2010 Wreshaffle2010 Sreshaffle2010 BSBreshaffle2010 SFreshaffle2010

[RDreshaffle2011,catchRD_max11,catchRD_min11]=CatchTripDistribution(N,M,T,percentile,RDdata2011.data);
save('CatchPerTrip2011','SFreshaffle2011','Sreshaffle2011','BSBreshaffle2011','Wreshaffle2011', 'RDreshaffle2011','catchSF_max11','catchSF_min11');
clearvars RDreshaffle2011 Wreshaffle2011 Sreshaffle2011 BSBreshaffle2011 SFreshaffle2011

[RDreshaffle2012,catchRD_max12,catchRD_min12]=CatchTripDistribution(N,M,T,percentile,RDdata2012.data);
save('CatchPerTrip2012','SFreshaffle2012','Sreshaffle2012','BSBreshaffle2012','Wreshaffle2012', 'RDreshaffle2012','catchSF_max12','catchSF_min12');
clearvars RDreshaffle2012 Wreshaffle2012 Sreshaffle2012 BSBreshaffle2012 SFreshaffle2012

[RDreshaffle2013,catchRD_max13,catchRD_min13]=CatchTripDistribution(N,M,T,percentile,RDdata2013.data);
save('CatchPerTrip2013','SFreshaffle2013','Sreshaffle2013','BSBreshaffle2013','Wreshaffle2013', 'RDreshaffle2013','catchSF_max13','catchSF_min13');
clearvars RDreshaffle2013 Wreshaffle2013 Sreshaffle2013 BSBreshaffle2013 SFreshaffle2013

[RDreshaffle2014,catchRD_max14,catchRD_min14]=CatchTripDistribution(N,M,T,percentile,RDdata2014.data);
save('CatchPerTrip2014','SFreshaffle2014','Sreshaffle2014','BSBreshaffle2014','Wreshaffle2014', 'RDreshaffle2014','catchSF_max14','catchSF_min14');
clearvars RDreshaffle2014 Wreshaffle2014 Sreshaffle2014 BSBreshaffle2014 SFreshaffle2014

[RDreshaffle2015,catchRD_max15,catchRD_min15]=CatchTripDistribution(N,M,T,percentile,RDdata2015.data);
save('CatchPerTrip2015','SFreshaffle2015','Sreshaffle2015','BSBreshaffle2015','Wreshaffle2015', 'RDreshaffle2015','catchSF_max15','catchSF_min15');
clearvars RDreshaffle2015 Wreshaffle2015 Sreshaffle2015 BSBreshaffle2015 SFreshaffle2015

[RDreshaffle2016,catchRD_max16,catchRD_min16]=CatchTripDistribution(N,M,T,percentile,RDdata2016.data);
save('CatchPerTrip2016','SFreshaffle2016','Sreshaffle2016','BSBreshaffle2016','Wreshaffle2016', 'RDreshaffle2016','catchSF_max16','catchSF_min16');
clearvars RDreshaffle2016 Wreshaffle2016 Sreshaffle2016 BSBreshaffle2016 SFreshaffle2016

[RDreshaffle2017,catchRD_max17,catchRD_min17]=CatchTripDistribution(N,M,T,percentile,RDdata2017.data);
save('CatchPerTrip2017','SFreshaffle2017','Sreshaffle2017','BSBreshaffle2017','Wreshaffle2017', 'RDreshaffle2017','catchSF_max17','catchSF_min17');
clearvars RDreshaffle2017 Wreshaffle2017 Sreshaffle2017 BSBreshaffle2017 SFreshaffle2017

[RDreshaffle2018,catchRD_max18,catchRD_min18]=CatchTripDistribution(N,M,T,percentile,RDdata2018.data);
save('\CatchPerTrip2018','SFreshaffle2018','Sreshaffle2018','BSBreshaffle2018','Wreshaffle2018', 'RDreshaffle2018','catchSF_max18','catchSF_min18');
clearvars RDreshaffle2018 Wreshaffle2018 Sreshaffle2018 BSBreshaffle2018 SFreshaffle2018

[RDreshaffle2019,catchRD_max19,catchRD_min19]=CatchTripDistribution(N,M,T,percentile,RDdata2019.data);
save('CatchPerTrip2019','SFreshaffle2019','Sreshaffle2019','BSBreshaffle2019','Wreshaffle2019', 'RDreshaffle2019','catchSF_max19','catchSF_min19');
clearvars RDreshaffle2019 Wreshaffle2019 Sreshaffle2019 BSBreshaffle2019 SFreshaffle2019

[RDreshaffle2020,catchRD_max20,catchRD_min20]=CatchTripDistribution(N,M,T,percentile,RDdata2020.data);
save('CatchPerTrip2020','SFreshaffle2020','Sreshaffle2020','BSBreshaffle2020','Wreshaffle2020', 'RDreshaffle2020','catchSF_max20','catchSF_min20');
clearvars RDreshaffle2020 Wreshaffle2020 Sreshaffle2020 BSBreshaffle2020 SFreshaffle2020

toc;